*****************
*Replication code for: 
*Davis, Nicholas T. and Matthew P. Hitt. 
*"Winning, Losing, and the Dynamics of External Political Efficacy."
*International Journal of Public Opinion Research
*If you use these data, please cite the original paper
*Use: Davis_Hitt_IJPOR_replication.dta
******************

*Table 1, column 1
*Winner vote, post-election waves

xtmixed ee obama_ libcon knowledge education male black hh_income age [pw=weight] || wave: obama_ if wave > 2, vce(oim) cov(uns) 

*Table 1, column 2
*Winner vote, all waves

xtmixed ee obama_ libcon knowledge education male black hh_income age [pw=weight] || wave: obama_, vce(oim) cov(uns)

*Table 1, column 3
*Loser vote, all waves

xtmixed ee mccainvote libcon knowledge education male black hh_income age [pw=weight] || wave: mccainvote, vce(oim) cov(uns)


*Figure 2

xtmixed ee obama_ libcon knowledge education male black hh_income age [pw=weight] || wave: obama_, vce(oim) cov(uns)

predict waveEffect_obama waveEffect_cons, reffects level(wave)

predict waveEffect_obamaSE waveEffect_consSE, reses  level(wave)

gen waveEffect_obamaUB = waveEffect_obama + 2 * waveEffect_obamaSE
gen waveEffect_obamaLB = waveEffect_obama - 2 * waveEffect_obamaSE

twoway rarea waveEffect_obamaUB waveEffect_obamaLB wave || connected waveEffect_obama wave


xtmixed ee mccainvote libcon knowledge education male black hh_income age [pw=weight] || wave: mccainvote, vce(oim) cov(uns)


predict waveEffect_mccain waveEffect_cons_mccain, reffects level(wave)

predict waveEffect_mccainSE waveEffect_consSE_mccain, reses  level(wave)

gen waveEffect_mccainUB = waveEffect_mccain + 2 * waveEffect_mccainSE
gen waveEffect_mccainLB = waveEffect_mccain - 2 * waveEffect_mccainSE


twoway rarea waveEffect_mccainUB waveEffect_mccainLB wave || connected waveEffect_mccain wave


